<template>
  <div class="containerx">
    <el-container>
      <el-header>
         <div class="header-box">
           <div class="header-left"><div class="logo">My-Shopping</div></div>
           <div class="header-right">
             <div class="header-right-item">
               {{user.username}}，欢迎登陆
             </div>
           </div>
         </div>
      </el-header>
      <el-container>
        <el-aside width="200px">
          <div class="menu-box">
            <el-menu
              active-text-color="#ffd04b"
              background-color="#545c64"
              class="el-menu-vertical-demo"
              router
              :default-active="$route.path"
              text-color="#fff"
              @open="handleOpen"
              @close="handleClose"
            >
              <el-menu-item index="/home/home">
                <span><i class="iconfont icon-zhuye"></i>&nbsp;主页</span>
              </el-menu-item>
              <el-menu-item index="/home/user">
                <span><i class="iconfont icon-yonghu"></i>&nbsp;用户管理</span>
              </el-menu-item>
              <el-menu-item index="/home/goods">
                <span><i class="iconfont icon-shangpin"></i>&nbsp;商品管理</span>
              </el-menu-item>
              <el-menu-item index="/home/order">
                <span><i class="iconfont icon-dingdan"></i>&nbsp;订单管理</span>
              </el-menu-item>
            </el-menu>
          </div>
        </el-aside>
        <el-main>
            <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script setup>
import { ref, onBeforeMount, computed } from 'vue'
import { useRouter } from 'vue-router'
import { useStore } from 'vuex'
const router = useRouter()
const store = useStore()

const user = computed(() => {
  return store.state.user.user
})

onBeforeMount(() => {
  store.dispatch('user/getMe')
})
</script>

<style lang="scss" scoped>
$navColor: #545c64;

::v-deep(.el-header) {
  padding: 0;
  height: 7vh;
}
::v-deep(.el-aside) {
  background-color: $navColor;
}
::v-deep(.el-main) {
  padding: 10px;
}

.containerx {
  height: 100vh;
  width: 100vw;
  .header-box {
    width: 100%;
    height: 100%;
    background-color: $navColor;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #fff;
    .header-left {
      padding-left: 10px;
      .logo {
        font-weight: bold;
        font-size: 24px;
      }
    }
    .header-right {
      padding-right: 10px;
    }
  }
  .menu-box {
    height: 93vh;
  }
}
</style>